'use strict'
let nunjucks = require('nunjucks');

let getContllFiles =function(path,opts){
    path = path || './views';
    opts = opts || {};
    let env = nunjucks.configure(path,opts)
    return env;
}

module.exports = async(ctx,next)=>{
    ctx.render = function(view,modle){
        let env = getContllFiles();
        ctx.body = env.render(view,modle);
    }
    await next();
}